<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

<script>

    //  1 3 2  => setTimeout异步任务
    // console.log(1);
    // setTimeout(function () {
    //     console.log(2);
    // }, 0);
    // console.log(3);



    console.log(1);
    var p = new Promise(function (resolve, reject) { //同步任务
        console.log(2);
        resolve(3);
    })

    // Promise实例的方法 then 和catch 也是异步任务
    p.then(num => {
        console.log(num);
    })
    console.log(4);



</script>

</html>